<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改申请记录')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-society-edit" th:object="${recordSociety}">
            <h4 class="form-header h4">申请记录信息</h4>
            <input name="societyId" th:field="*{societyId}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">人员类型：</label>
                <div class="col-sm-8">
                    <select name="userType" id="userType" class="form-control m-b">
                        <option value="01" th:selected="*{userType == '01'}">普通职工</option>
                        <option value="02" th:selected="*{userType == '02'}">科级干部</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">专业：</label>
                <div class="col-sm-8">
                    <input id="major" name="major" class="form-control" type="text" th:field="*{major}" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">参加学会、协会名称：</label>
                <div class="col-sm-8">
                    <input id="societyTitle" name="societyTitle" class="form-control" type="text" th:field="*{societyTitle}" required>
                </div>
            </div>
            <div class="form-group select-time">
                <label class="col-sm-3 control-label is-required">开始时间：</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control time-input" data-type="month" id="startTime" th:field="*{startTime}" name="startTime" />
                </div>
            </div>
            <div class="form-group select-time">
                <label class="col-sm-3 control-label is-required">结束时间：</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control time-input" data-type="month" id="endTime" th:field="*{endTime}" name="endTime" />
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <textarea name="remark" class="form-control">[[*{remark}]]</textarea>
                </div>
            </div>
            <h4 class="form-header h4">已参加学会、协会</h4>
            <div class="row">
                <div class="col-sm-12">
                    <button type="button" class="btn btn-white btn-sm" onclick="addColumn()"><i class="fa fa-plus"> 增加</i></button>
                    <button type="button" class="btn btn-white btn-sm" onclick="sub.delColumn()"><i class="fa fa-minus"> 删除</i></button>
                    <div class="col-sm-12 select-table table-striped">
                        <table id="bootstrap-table"></table>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "record/society";
        $("#form-society-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-society-edit').serialize());
            }
        }

        $(function() {
            var options = {
                data: [[${recordSociety.recordSocietyContentList}]],
                pagination: false,
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                sidePagination: "client",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'index',
                    align: 'center',
                    title: "序号",
                    formatter: function (value, row, index) {
                    	var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
                    	return columnIndex + $.table.serialNumber(index);
                    }
                },
                {
                    field: 'societyTitle',
                    align: 'center',
                    title: '已参加学会、协会名称',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='recordSocietyContentList[%s].societyTitle' value='%s'>", index, value);
                        return html;
                    }
				},
                {
                    field: 'startTime',
                    align: 'center',
                    title: '开始时间',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='recordSocietyContentList[%s].startTime' value='%s'>", index, value);
                        return html;
                    }
				},
                {
                    field: 'endTime',
                    align: 'center',
                    title: '结束时间',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='recordSocietyContentList[%s].endTime' value='%s'>", index, value);
                        return html;
                    }
				}]
            };
            $.table.init(options);
        });

        function addColumn() {
            var count = $("#" + table.options.id).bootstrapTable('getData').length;
            sub.editColumn();
        	
            $("#" + table.options.id).bootstrapTable('insertRow', {
                index: count,
                row: {
                    index: $.table.serialNumber(count),
                    societyTitle: "",
                    startTime: "",
                    endTime: ""
        	    }
            });
        }
    </script>
</body>
</html>